package top.hjcwzx.wrench.mqtt.strategy;

import top.hjcwzx.wrench.mqtt.enums.MessageHandlerStrategyEnum;

import java.util.Map;

/**
 *
 * <p><b>类名：</b> MqttMessageManager</p>
 * <p><b>描述：</b> 消息管理器</p>
 * <p><b>创建时间：</b> 2025-06-17 17:01</p>
 *
 * @author 胡锦程
 */
public class MqttMessageManager {

    private final Map<String, MqttMessageHandler> mqttMessageHandlerGroup;

    public MqttMessageManager(Map<String, MqttMessageHandler> mqttMessageHandlerGroup) {
        this.mqttMessageHandlerGroup = mqttMessageHandlerGroup;
    }


    public MqttMessageHandler getMqttMessageHandler(MessageHandlerStrategyEnum strategyEnum) {
        return mqttMessageHandlerGroup.getOrDefault(strategyEnum.getBeanName(),
                mqttMessageHandlerGroup.get(MessageHandlerStrategyEnum.ANNOTATION_CALLBACK.getBeanName()));
    }
}
